/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package familytree.struts.forms;

import familytree.negocio.IAlbumProcessor;
import familytree.negocio.IImagenProcessor;
import familytree.negocio.bo.AlbumBO;
import familytree.negocio.bo.ImagenBO;
import familytree.persistencia.pojos.Album;
import familytree.persistencia.pojos.Imagen;
import familytree.persistencia.pojos.Nodo;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.apache.struts.util.LabelValueBean;

/**
 *
 * @author Antonio
 */
public class MediaForm extends ActionForm {
    
   private Album album;

    public Album getAlbum() {
        return album;
    }

    public void setAlbum(Album album) {
        this.album = album;
    }   
   
   /**
    *
    */
   public MediaForm() {
      album = new Album();
   }

    @Override
    public void reset(ActionMapping arg0, HttpServletRequest arg1) {
        
        Nodo nodo = (Nodo) arg1.getSession().getAttribute("nodoActual");
        String ruta = arg1.getSession().getServletContext().getRealPath("");
        IImagenProcessor imagenBO = new ImagenBO();
        IAlbumProcessor albumBO = new AlbumBO();
        
        
        Map<String,File> imagenesPortada = albumBO.getImagenesPortadas(nodo, ruta);
        List<Album> albumes = albumBO.getAlbumes(nodo);
        
        arg1.setAttribute("albumes", albumes);
        arg1.setAttribute("imagenesPortada", imagenesPortada);
        
        List<Imagen> imagenes = imagenBO.getFotosRecientes(nodo,ruta);
        arg1.setAttribute("imagenesRecientes", imagenes);
        
    }
}
